package com.zj.base.permission.manifests;

import android.Manifest;

import com.zj.base.permission.ConfigurationModules;

import java.lang.reflect.Field;

import static com.zj.base.permission.PermissionTools.appName;


/**
 * Created by zhaojie on 2018/5/18.
 */

@SuppressWarnings("unused")
public final class PermissionsManifest {
    /**
     *
     * */
    public static final String FINE_LOCATION = "fine_location";
    public static final String COARSE_LOCATION = "coarse_location";
    public static final String READ_PHONE_STATE = "readPhoneState";
    public static final String READ_CONTACTS = "readContacts";
    public static final String READ_EXTERNAL_STORAGE = "readExternalStorage";
    public static final String WEITE_EXTERNAL_STORAGE = "writeExternalStorage";
    public static final String WRITE_SYSTEM_SITTINGS = "writeSystemSittings";
    public static final String CAMERA = "camera";
    public static final String ACCESS_WIFI_STATE = "wifi";


    /**
     * used in CheckPermissionTools ,it should not use at other place
     */
    public static ConfigurationModules getAnnotationType(String code) {
        try {
            Class<Config> cls = Config.class;
            Field[] fields = cls.getDeclaredFields();
            for (Field value : fields) {
                if (value.getName().equals(code)) {
                    return ((ConfigurationModules) value.get(ConfigurationModules.class));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        throw new NullPointerException("annotationType with " + code + " is not found in Config.class\ncheck is exists field with your code or check your code is field name in Config.class?");
    }

    /**
     * @see Op_PermissionCheekUtils
     * the field was called by reflex method
     * @see ConfigurationModules know the ConfigurationModules parameter detail
     */
    public static class Config {
        public static final ConfigurationModules fine_location = new ConfigurationModules(Manifest.permission.ACCESS_FINE_LOCATION, appName + "需要您同意授权获取您的大致位置，以便更好的为您服务。", "大致位置（基于GPS）", "isLocationUse", Op_PermissionCheekUtils.Manifest.OP_FINE_LOCATION);
        public static final ConfigurationModules coarse_location = new ConfigurationModules(Manifest.permission.ACCESS_COARSE_LOCATION, appName + "需要您同意授权获取您的大致位置，以便更好的为您服务。", "大致位置（基于网络）", "isLocationUse", Op_PermissionCheekUtils.Manifest.OP_COARSE_LOCATION);
        public static final ConfigurationModules readPhoneState = new ConfigurationModules(Manifest.permission.READ_PHONE_STATE, appName + "需要获取您的电话及网络信息，以便更好的为您服务。", "读取手机状态信息", "", Op_PermissionCheekUtils.Manifest.OP_READ_PHONE_STATE);
        public static final ConfigurationModules readContacts = new ConfigurationModules(Manifest.permission.READ_CONTACTS, appName + "请求访问您的手机通讯录，以便更好的为您服务。", "访问手机通讯录", "isReadConstantsUse", Op_PermissionCheekUtils.Manifest.OP_READ_CONTACTS);
        public static final ConfigurationModules readExternalStorage = new ConfigurationModules(Manifest.permission.READ_EXTERNAL_STORAGE, appName + "需要您同意授权访问您的本地储存，以便更好的为您服务。", "读取SD卡数据", "isExternalStorageUsed", Op_PermissionCheekUtils.Manifest.OP_READ_EXTERNAL_STORAGE);
        public static final ConfigurationModules writeExternalStorage = new ConfigurationModules(Manifest.permission.WRITE_EXTERNAL_STORAGE, appName + "需要您同意授权访问您的本地储存，以便更好的为您服务。", "写入SD卡数据", "isExternalStorageUsed", Op_PermissionCheekUtils.Manifest.OP_WRITE_EXTERNAL_STORAGE);
        public static final ConfigurationModules writeSystemSittings = new ConfigurationModules(Manifest.permission.WRITE_SETTINGS, appName + "需要您同意授权访问您的设置选项，以便更好的为您服务。", "读取或修改系统设置", "", Op_PermissionCheekUtils.Manifest.OP_WRITE_SETTINGS);
        public static final ConfigurationModules camera = new ConfigurationModules(Manifest.permission.CAMERA, appName + "需要您同意使用您的相机设备，以便更好的为您服务。", "相机/摄像头", "isCameraUse", Op_PermissionCheekUtils.Manifest.OP_CAMERA);
        public static final ConfigurationModules wifi = new ConfigurationModules(Manifest.permission.ACCESS_WIFI_STATE, appName + "需要您同意查看您的WIFI设置，可以帮助您避免流量的浪费。", "WIFI设置", "", Op_PermissionCheekUtils.Manifest.OP_WIFI_SCAN);
    }
}
